﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using strange.extensions.command.impl;
using System.IO;

public class StartCommand : EventCommand {
    [Inject]
    public CardModel CardModel { get; set; }
    [Inject]
    public RoundModel RoundModel { get; set; }
    [Inject]
    public IntegrationModel IntegrationModel { get; set; }
    /// <summary>
    /// 执行命令
    /// </summary>
    public override void Execute()
    {
        Tools.CreateUIPanel(PanelType.StartPanel);
        //初始化model
        //初始化牌库
        CardModel.InitCardLibrary();
        //初始化回合
        RoundModel.InitRound();
        //初始化积分
        IntegrationModel.InitIntegration();

        //得到初始化积分数据
        GetData();
    }
    /// <summary>
    /// 读取数据
    /// </summary>
    private void GetData()
    {
        string fileName = Consts.DataPath;
        //文件里的信息
        FileInfo fileInfo = new FileInfo(fileName);
        if (fileInfo.Exists)
        {
            //获取数据
            GameData oldData = Tools.GetDataOutBOM();
            //保存数据
            IntegrationModel.PlayerIntegration = oldData.PlayerIntegration;
            IntegrationModel.ComputerLeftIntegration = oldData.ComputerLeftIntegration;
            IntegrationModel.ComputerRightIntegration = oldData.ComputerRightIntegration;
        }
    }
}
